﻿using Microsoft.AspNetCore.Mvc;
using store.cyt369.com.MODELS;
using store.cyt369.com.models;

namespace store.cyt369.com.Controllers
{
    class UpperCaseNamingPolicy : System.Text.Json.JsonNamingPolicy
    {
        public override string ConvertName(string name)
        {
            return name;
        }
    }


    public class BaseController : Controller
    {

        public store.cyt369.com.Models.UserSession UserSession
        {
            get
            {
                return HttpContext.RequestServices.GetService(typeof(store.cyt369.com.Models.UserSession)) as store.cyt369.com.Models.UserSession;
            }
        }

        public ContentResult Content(bool b)
        {
            return base.Content(b.ToString().ToLower());
        }

        public JsonResult DefaultJson(object obj)
        {
            var setting = new System.Text.Json.JsonSerializerOptions()
            {
                PropertyNamingPolicy = new UpperCaseNamingPolicy()
            };


            return base.Json(obj, setting);
        }
    }
}
